<article id="wikiArticle">
<div> <div class="blockIndicator nonStandard nonStandardHeader">
<p><strong><span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span> 非标准</strong><br/>
      该特性是非标准的，请尽量不要在生产环境中使用它！</p>
</div></div>
<h2 id="概述">概述</h2>
<p>判断一个函数是否是一个<a href="/zh-cn/JavaScript/Guide/Iterators_and_Generators#Generators.3a_a_better_way_to_build_Iterators" title="zh-cn/Core JavaScript 1.5 Guide/Iterators and Generators#Generators.3a a better way to build Iterators">生成器</a>.</p>
<h2 id="语法">语法</h2>
<pre><code class="language-javascript"><code><var>fun</var>.isGenerator()</code></code></pre>
<h2 id="描述">描述</h2>
<p>该方法用来判断一个函数是否是一个<a href="/zh-cn/JavaScript/Guide/Iterators_and_Generators#Generators.3a_a_better_way_to_build_Iterators" title="zh-cn/Core JavaScript 1.5 Guide/Iterators and Generators#Generators.3a a better way to build Iterators">生成器</a>.</p>
<h2 id="例子">例子</h2>
<pre><code  class="language-javascript">function f() {}
function* g() {
  yield 42;
}
console.log("f.isGenerator() = " + f.isGenerator());
console.log("g.isGenerator() = " + g.isGenerator());
</code></pre>
<p>上面代码的输出结果为</p>
<pre>f.isGenerator() = false
g.isGenerator() = true 
</code></pre>
<h2 id="相关链接">相关链接</h2>
<ul>
<li><a href="/zh-cn/JavaScript/Guide/Iterators_and_Generators" title="zh-cn/Core JavaScript 1.5 Guide/Iterators and Generators">迭代器和生成器</a></li>
</ul>
</article>